cmake_minimum_required(VERSION 3.1.3)
project(all-test)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")

# 设置默认并行编译线程数（通过CMake变量传递）
if(NOT DEFINED ENV{MAKEFLAGS})
    set(CMAKE_BUILD_PARALLEL_LEVEL 4)  # 默认使用4线程（适配4核）
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
    add_compile_options(-flto)
    add_link_options(-flto=4)  # 4线程LTO链接
endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/message)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/user)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/file)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/speech)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/transmite)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/friend)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/gateway)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})